﻿function Environment() { }
var E = Environment;
E.getBrowserNameWithVersion = function()
{
	if (E.browser.msie)
	{
		if (document.getElementById && document.compatMode && !window.XMLHttpRequest) return "msie6";
		if (document.getElementById && document.compatMode && window.XMLHttpRequest && !document.documentMode) return "msie7";
		if (document.getElementById && document.compatMode && window.XMLHttpRequest && document.documentMode) return "msie8";
	}
	return E.getBrowserName() + parseInt(navigator.appVersion);
};

var userAgent = navigator.userAgent.toLowerCase();
E.browser = {
	chrome: /chrome/.test(userAgent),
	safari: /webkit/.test(userAgent) && !/chrome/.test(userAgent),
	opera: /opera/.test(userAgent),
	msie: /msie/.test(userAgent) && !/opera/.test(userAgent),
	firefox: /mozilla/.test(userAgent) && !/(compatible|webkit)/.test(userAgent)
};
E.browser.webkit = E.browser.chrome || E.browser.safari;

E.getHostName = Path.getHostName;

E.getBrowserName = function()
{
	if (E.browser.chrome) return "chrome";
	if (E.browser.safari) return "safari";
	if (E.browser.opera) return "opera";
	if (E.browser.msie) return "msie";
	if (E.browser.firefox) return "firefox";
};
E.browser[E.getBrowserNameWithVersion()] = true; //msie8 = true;

E.resNames = ["res-low", "res-1280", "res-high"];
E.getResolutionName = function()
{
	var w = $(window).width();
	if (w <= 1024) return E.resNames[0];
	if (w <= 1280) return E.resNames[1];
	if (w > 1280) return E.resNames[2];
	return "res-low";
};
E.getValueByResolutionWidth = function(low, medium, high)
{
	var w = $(window).width();
	if (w <= 1024) return low;
	if (w <= 1280) return medium;
	if (w > 1280) return high;
	return low;
};
E.getValueByResolutionHeight = function(low, med800, med1050, high)
{
	var windowHeight = $(window).height();
	//header size
	var unavailableResolution = 181;
	if (E.browser.firefox) unavailableResolution = 181;
	if (E.browser.safari) unavailableResolution = 91;
	if (E.browser.chrome) unavailableResolution = 99;
	if (E.browser.msie8) unavailableResolution = 131;

	//alert(windowHeight + ":" + (768 - windowHeight) + ":" + (768 - unavailableResolution));
	if (windowHeight <= 768 - unavailableResolution) return low;
	if (windowHeight <= 800 - unavailableResolution) return med800;
	if (windowHeight <= 1050 - unavailableResolution) return med1050;
	if (windowHeight > 1050 - unavailableResolution) return high;
	return low;
};
